package com.dxy.controller;

import com.dxy.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.tools.ForwardingFileObject;
import java.nio.file.Path;

@Controller
@RequestMapping(path = "/he")
public class Hello {
//    @RequestMapping(path = "/hello2")
//    public ModelAndView say2(){
//        ModelAndView mv=new ModelAndView();
//        User u=new User();
//        u.setUsername("root");
//        u.setPassword("123456");
//        u.setAge(18);
//        mv.addObject("u",u);
//        mv.setViewName("success");
//        return mv;
//    }
//    @RequestMapping(path = "/update")
//    public String update(User u){
//        System.out.println(u);
//        return "success";
//    }
//    @RequestMapping(path = "/forword222")
//    public String forword222(){
////        return "forward:/WEB-INF/pages/success.jsp";
//   //     return "forward:hello2";
//        return "redirect:/he/hello2";
//    }

    @RequestMapping(path ="/jax")
    @ResponseBody
    public User jax(@RequestBody User b){
        System.out.println(b);
        User u=new User();
        u.setAge(18);
        u.setPassword("123");
        u.setUsername("sss");
        return u;
    }
}
